--author Erasor84

function AutoExtract_OnLoad(this)
	this:RegisterEvent("VARIABLES_LOADED");
	this:RegisterEvent("PLAYER_BAG_CHANGED");
--	SaveVariables("AutoExtract_Vars");
	DEFAULT_CHAT_FRAME:AddMessage("AutoExtract loaded.",0.1,0.6,0.90);
end;

function AutoExtract_OnEvent(this,event,arg1,arg2)
	if(event == "PLAYER_BAG_CHANGED")then
		AutoExtract_ExtractItem();
	end;
end;

function AutoExtract_ExtractItem()
    local index, texture, name, count, quality;
    local maxNum = GetBagCount();
    for i = 0, GetBagCount() do
		index,texture,name,itemCount,locked,invalid = GetBagItemInfo(i);
		if (string.find(name,"Unbekannte Pflanze") or
		    string.find(name,"Unbekanntes Erz") or
		    string.find(name,"Unknown Agricultural Product") or
		    string.find(name,"Unknown Ore")) then
			UseItemByName(name);
		end; 
	end;
end;